﻿@using CodeCamp.Models.Shared
@model CodeCamp.Models.Email.EmailItemsListWithSearchViewModel

@{
    Layout = "~/Views/Shared/_LayoutWideSimple.cshtml";
    ViewBag.Title = "";
    if ((@Model != null) && (@Model.EventDisplayName != null))
    {
        ViewBag.Title = @Html.Encode(@Model.EventDisplayName + " | Campaign Emails");
    }
    else
    {
        ViewBag.Title = "Code Camp | Campaign Emails";
    }
}

@section headaddon {
<style>
    table
    {
        border-collapse: collapse;
        border: solid 1px;
        margin: 0;
    }
    th
    {
        padding: 4px;
    }
    td 
    {
        padding: 4px;
    }
    #content
    {
        width: 900px;
        overflow:scroll;
    }
</style>
}

<h2>Email Campaign Email List</h2>
<p style="text-align:center;">@Model.EmailCampaignDescription</p>
<h3>@string.Format("Campaign {0}: {1}", Model.EmailCampaignId, Model.EmailCampaignStatus)</h3>

@if ((Model.CanAddEmailsToCampaign && (Model.SearchModel != null))
    || ((Model.SiteUserList != null) && (Model.SiteUserList.Count > 0)))
{
<table>
    <tr>
        <td>
@if (Model.CanAddEmailsToCampaign && (Model.SearchModel != null))
{
    @Html.Partial("EmailAddSearchPartial", Model.SearchModel)
}
@if (!string.IsNullOrWhiteSpace(Model.ResultMessage))
{
    <h3>@Model.ResultMessage</h3>
}
        </td>
@if ((Model.SiteUserList != null) && (Model.SiteUserList.Count > 0))
{
        <td>
    @Html.Partial("SiteUserListPartial", Model.SiteUserList)
        </td>
}
    </tr>
</table>
}
else if (!string.IsNullOrWhiteSpace(Model.ResultMessage))
{
    <h3>@Model.ResultMessage</h3>
}

<p style="text-align:center;">
@Html.ActionLink("Campaigns List", "EmailCampaigns")
@if (Model.EmailCampaignId.HasValue)
{
    <text> | </text>@Html.ActionLink("Edit Campaign", "EmailCampaignEdit", new { eventName = Model.EventShortName, id = Model.EmailCampaignId.Value })
    if (Model.CanAddEmailsToCampaign)
    {
    <text> | </text>@Html.ActionLink("Add Email", "EmailCampaignAddEmail", new { eventName = Model.EventShortName, id = Model.EmailCampaignId.Value })
    }
}</p>

@if (!string.IsNullOrWhiteSpace(ViewBag.SendResultMessage))
{
    <h3>@ViewBag.SendResultMessage</h3>
}

@if (Model.EmailItems != null)
{
    <div style="min-height:200px;">
    @Html.Partial("Partial/EmailItemsListPartial", @Model.EmailItems)
    </div>
}

@section sidebar {
    @if (User.IsInRole(CCRoles.RoleNames.BigCheeze))
    {
    <div id="eventTagsContainer" class="widget rounded-10">
    <ul>
        <li>@Html.ActionLink("Back to Email Home", "Index")</li>
        <li><i>@Html.ActionLink("Campaigns", "EmailCampaigns")</i>
            <ul>
                <li>&nbsp;&nbsp;<i>Campaign Emails</i></li>
            </ul>
        </li>
        <li>@Html.ActionLink("Recent Emails", "RecentEmails")
        <li>
            Email Tests:
            <ul>
                <li>@Html.ActionLink("Basic Test", "TestBasicMail")</li>
            </ul>
        </li>
    </ul>
    </div>
    }
}
